package action.chap4;

import java.util.List;
import java.util.stream.Collectors;

public class Demo07 {
    public static void main(String[] args) {
        List<Dish> menu = DishUtils.getListDish();
        List<Dish> collect = menu.stream().filter(dish -> dish.getCalories() > 300).limit(3).collect(Collectors.toList());
        collect.forEach(
                System.out::println
        );
        System.out.println("============================");
        // 这里跳过了前两个数据
        List<Dish> collect1 = menu.stream().filter(dish -> dish.getCalories() > 300).skip(2).collect(Collectors.toList());

        collect1.forEach(System.out::println);
        //
        System.out.println("你将如何利用流来筛选前两个荤菜呢？");
        List<Dish> collect2 = menu.stream().filter(dish -> dish.getType() == Dish.Type.MEAT).limit(2).collect(Collectors.toList());


    }
}
